﻿using System.Collections;
using System.Collections.Generic;
using Entitas;
using UnityEngine;

public class DestroySystem : ICleanupSystem
{
    private Contexts _contexts;
    private IGroup<GameEntity> _group;
    private List<GameEntity> _buffer=new List<GameEntity>();

    public DestroySystem(Contexts contexts)
    {
        _contexts = contexts;
        _group = _contexts.game.GetGroup(GameMatcher.ComponentsDestroy);
        
    }
    
    public void Cleanup()
    {
        foreach (GameEntity entity in _group.GetEntities(_buffer))
        {
            entity.Destroy();
        }
    }

    
}
